import { getRawValueLabeled } from '../utils/valueUtil';
import { formatStrategyKeys } from '../utils/strategyUtil';
import { shallowRef, watchEffect } from 'vue';
/** Return  */

export default function useSelectValues(rawValues, _ref) {
  var value = _ref.value,
      getEntityByValue = _ref.getEntityByValue,
      getEntityByKey = _ref.getEntityByKey,
      treeConduction = _ref.treeConduction,
      showCheckedStrategy = _ref.showCheckedStrategy,
      conductKeyEntities = _ref.conductKeyEntities,
      getLabelProp = _ref.getLabelProp;
  var rawValueLabeled = shallowRef([]);
  watchEffect(function () {
    var mergedRawValues = rawValues.value;

    if (treeConduction.value) {
      var rawKeys = formatStrategyKeys(rawValues.value.map(function (val) {
        var entity = getEntityByValue(val);
        return entity ? entity.key : val;
      }), showCheckedStrategy.value, conductKeyEntities.value);
      mergedRawValues = rawKeys.map(function (key) {
        var entity = getEntityByKey(key);
        return entity ? entity.data.value : key;
      });
    }

    rawValueLabeled.value = getRawValueLabeled(mergedRawValues, value.value, getEntityByValue, getLabelProp);
  });
  return rawValueLabeled;
}